<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // - 回调地狱  callback  > 
        // es6 Promise  then 异步同步化 代码的编写顺序和执行顺序一样
        const async1 = async () => {
            console.log('async1');
            setTimeout(() => {  // 把定时器放到宏任务中
                console.log('timer1')
            },2000)
            await new Promise(resolve => { // promise status :pending}
                console.log('promise') // resolved 没解决
            })
            console.log('async1 end');
            return 'async1 success'
        }
        console.log('script start')
        async1().then(res => console.log(res,'--'))
        console.log('script end')
        Promise.resolve(1)  // 静态方法
            .then(2)
            .then(Promise.resolve(3))
            .then(res => console.log(res))
        setTimeout(() => {
            console.log('timer2')
        },1000)
    </script>
</body>
</html>